package com.lpwa.framework.netty;

import com.lpwa.common.utils.RedisUtil;
import com.lpwa.framework.netty.entity.AoaResultRaw;
import com.lpwa.framework.netty.utils.NettyByteAndStringUtils;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelId;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalTime;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author June
 * @description
 */
@Slf4j
public class NettySendThread implements Runnable {

    private ChannelHandlerContext ctx;
    private String data;
    public NettySendThread(ChannelHandlerContext ctx, String data) {
        this.ctx = ctx;
        this.data = data;
    }

    @Override
    public void run() {
        String bcc = NettyDataSvervice.sendData(data,ctx);
//        log.info("接收需要返回的消息：" + bcc);
        if (Objects.isNull(bcc)) {
            return;
        }
//        System.out.println(ctx.channel().id().toString());
//        nettyServerHandler.saveMacReChannel(bcc,ctx);
        //数据的发送与接收都是16进制
//        byte[] sendData = NettyByteAndStringUtils.hexToByte(bcc);
//        log.info("发送数据时间: " + LocalTime.now());
//        ctx.writeAndFlush(sendData);
    }
}
